﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Copy4Backup
{
	/// <summary>
	/// Holds disk information.
	/// </summary>
	public sealed class Disk
	{
		#region Fields
		#endregion Fields

		#region Properties

		/// <summary>
		/// Gets the location path.
		/// </summary>
		public String Location
		{
			get;
			private set;
		}

		/// <summary>
		/// Gets the disk capacity in bytes.
		/// </summary>
		public Int64 Capacity
		{
			get;
			private set;
		}

		/// <summary>
		/// Gets the disk sequence number.
		/// </summary>
		public int Number
		{
			get;
			private set;
		}

		/// <summary>
		/// Gets or sets the used disk space in bytes.
		/// </summary>
		public Int64 Used
		{
			get;
			set;
		}

		/// <summary>
		/// Gets the disk name in the format "DISKNN", where NN is disk number,
		/// </summary>
		public String DiskName
		{
			get
			{
				return String.Format("DISK{0}", Number.ToString("00"));
			}
		}
		#endregion Properties

		#region Methods

		/// <summary>
		/// Prevents a default instance of the Disk class from being created.
		/// </summary>
		private Disk()
		{
		}

		/// <summary>
		/// Initializes a new instance of the Disk class.
		/// </summary>
		/// <param name="capacity">Disk capacity in bytes.</param>
		/// <param name="location">Disk content location path.</param>
		/// <param name="number">Disk sequence number.</param>
		public Disk(long capacity, string location, int number)
		{
			Capacity = capacity;
			Location = location;
			Number = number;
			Used = 0;
		}

		/// <summary>
		/// Gets the text representation of the instance.
		/// </summary>
		/// <returns>The text representation of the instance.</returns>
		public override string ToString()
		{
			StringBuilder buffer = new StringBuilder("Disk:");
			buffer.AppendFormat(" Capacity = {0}", Capacity.ToString("N0"));
			buffer.AppendFormat(", Location = {0}", Location.ToString());
			buffer.AppendFormat(", Number = {0}", Number.ToString("00"));
			buffer.AppendFormat(", Used = {0}", Used.ToString("N0"));
			buffer.AppendFormat(", DiskName = {0}", DiskName.ToString());

			return buffer.ToString();
		}
		#endregion Methods
	}
}
